package com.itheima.practice1;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
//        1.将课堂上的自定义练习案例敲一遍。

        Class aClass = Class.forName("com.itheima.practice1.Student");
        Constructor declaredConstructor = aClass.getDeclaredConstructor();
        Student s = (Student) declaredConstructor.newInstance();

        Method[] methods = aClass.getDeclaredMethods();
        for (Method method : methods) {
            if(method.isAnnotationPresent(An2.class)){
                method.invoke(s);//记得 注释类要 @Retention(value = RetentionPolicy.RUNTIME)
            }
        }
    }
}
